<%@ page language="java" contentType="text/html; charset=windows-1255" pageEncoding="windows-1255"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<!-- RichFaces tag library declaration -->
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <script type="text/javascript">
            function fillCst(id,acco,loc,state,zip,country, sgcomponent){
            	loc.value =sgcomponent.getSelectedItems().pluck('location');
            	id.value =sgcomponent.getSelectedItems().pluck('id');
            	acco.value =sgcomponent.getSelectedItems().pluck('accountancyId');
            	state.value =sgcomponent.getSelectedItems().pluck('state');
            	zip.value =sgcomponent.getSelectedItems().pluck('zipCode');
            	country.value =sgcomponent.getSelectedItems().pluck('country');
            }

            function backup(org,hid){
                hid.value = org.value;
            }
            function restor(org,hid){
                org.value=hid.value ;
                
            }
        </script>
      <body>
            <f:view>
            <%@include file="../inc/menu.inc" %>
            <f:loadBundle basename="il" var="mes"/>
            	<a4j:form>
            	<h:outputText style="font-size:30;color:#680000" value="#{mes.menu_de_customer}" />
             		    <br>
             		    <br>
					<rich:tabPanel>
						<rich:tab label="#{mes.cust_crt_tab }">
							<h:outputText value="#{mes.cust_name} "/>&nbsp;
							<h:inputHidden  id = "back" value="" />
	                   		<h:inputText  id="customerI2" value = "#{customerEditManagedBean.customer.name}"/>&nbsp;
	                        <rich:suggestionbox  for="customerI2" var="customer" suggestionAction="#{customerEditManagedBean.autoCompleteCustomer}"
	         				 onbeforedomupdate="backup(#{rich:element('customerI2')},#{rich:element('back')});"	                       
	                         onselect="restor(#{rich:element('customerI2')},#{rich:element('back')});"
	           				 id="suggestionC2" >
	                         	
	                       		      <h:column>
	                       		     <h:outputText value="#{customer.name}" />
	                       		     </h:column>
	                             
	                      			   </rich:suggestionbox>
	                   		<h:outputText value="#{mes.cust_acc} "/>&nbsp;
	                   		<h:inputText  value = "#{customerEditManagedBean.customer.accountancyId}"/>&nbsp;
	                   		<h:outputText value="#{mes.cust_city} "/>&nbsp;
	                   		<h:inputText  value = "#{customerEditManagedBean.customer.location}"/>&nbsp;
	                   		<br>
	                   		<br>
							<h:outputText value="#{mes.cust_state} "/>&nbsp;
	                   		<h:inputText  value = "#{customerEditManagedBean.customer.state}"/>&nbsp;
	                   		<h:outputText value="#{mes.cust_country} "/>&nbsp;
	                   		<h:inputText  value = "#{customerEditManagedBean.customer.country}"/>&nbsp;
	                   		<h:outputText value="#{mes.cust_zip} "/>&nbsp;
	                   		<h:inputText  value = "#{customerEditManagedBean.customer.zipCode}"/>&nbsp; 
	                   		<br>
	                   		<br>
	                   		<h:commandButton action="#{customerEditManagedBean.createCustomer}" value="#{mes.cust_crate }" />	  	  
						</rich:tab>
						<rich:tab label="#{mes.cust_edit_tab }">
							<h:outputText value="#{mes.cust_name} "/>&nbsp;
	                   	    <h:inputText id="customerI" value="#{customerEditManagedBean.customerE.name}" />
	                        		 <rich:suggestionbox for="customerI" var="customer" suggestionAction="#{customerEditManagedBean.autoCompleteCustomer}" 
	           						  usingSuggestObjects="true"
	           						 onobjectchange="fillCst(#{rich:element('customerID')},#{rich:element('customerA')},#{rich:element('customerL')}, #{rich:element('customerS')},#{rich:element('customerZ')},#{rich:element('customerC')},#{rich:component('suggestionC')});"
	           						 id="suggestionC">
	                         
	                       		      <h:column>
	                       		     <h:outputText value="#{customer.name}" />
	                       		     </h:column>
	                            
	                      			   </rich:suggestionbox>
	                      	<h:inputHidden  id = "customerID" value="#{customerEditManagedBean.customerE.id}" />		   
	                   		<h:outputText value="#{mes.cust_acc} "/>&nbsp;
	                   		<h:inputText id = "customerA" value = "#{customerEditManagedBean.customerE.accountancyId}"/>&nbsp;
	                   		<h:outputText value="#{mes.cust_city} "/>&nbsp;
	                   		<h:inputText  id = "customerL" value = "#{customerEditManagedBean.customerE.location}"/>&nbsp;
	                   		<br>
	                   		<br>
							<h:outputText value="#{mes.cust_state} "/>&nbsp;
	                   		<h:inputText id = "customerS"  value = "#{customerEditManagedBean.customerE.state}"/>&nbsp;
	                   		<h:outputText value="#{mes.cust_country} "/>&nbsp;
	                   		<h:inputText id = "customerC" value = "#{customerEditManagedBean.customerE.country}"/>&nbsp;
	                   		<h:outputText  value="#{mes.cust_zip} "/>&nbsp;
	                   		<h:inputText id = "customerZ" value = "#{customerEditManagedBean.customerE.zipCode}"/>&nbsp; 
	                   		<br>
	                   		<br>
	                   		<h:commandButton action="#{customerEditManagedBean.updateCustomer}" value="#{mes.cust_update }" />
						</rich:tab>						
					</rich:tabPanel>
				</a4j:form>
            </f:view>
      </body>
      </html>

